import React, { Component } from 'react';
import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
import mypdf from "./SJKHDHSD.pdf";
import { Button } from 'antd';

export default class Pdf extends Component {
    state = {
      numPages: null,
      pageNumber: 1,
    };
    componentDidMount(){
        console.log(typeof(window.screen.width))
    }



    onDocumentLoadSuccess = ({ numPages }) => {
      this.setState({ numPages });
    };
    render() {
      const { pageNumber, numPages } = this.state;
      return (
        <div style={{width:"300px"}}>
          <Document
          style={{width:"50px"}}
            file={mypdf}
            onLoadSuccess={this.onDocumentLoadSuccess}
          >
             <Page width={300} pageNumber={pageNumber} />
          </Document>
          <Button
          onClick={() => {
            pageNumber > 1
              ? this.setState({ pageNumber: pageNumber - 1 })
              : alert('前面没有了');
          }}
        >
          上一页
        </Button>
        <Button
          onClick={() => {
            pageNumber < numPages
              ? this.setState({ pageNumber: pageNumber + 1 })
              : alert('后面没有了');
          }}
        >
          下一页
        </Button>

        </div>
      );
    }
  }
